<script setup lang="ts">
defineOptions({
  name: "baseModel"
});

import { ref, inject } from "vue";
import modelBox from "@/views/common/components/modelBox/index.vue";
import { ReTags } from "@/components/ReTags";
import ReTextTooltip from "@/components/ReTextTooltip";

const loading = inject<any>("loading", ref<boolean>(false));

interface Props {
  title: string;
  dataInfo: any[];
}
const props = withDefaults(defineProps<Props>(), {
  title: "",
  dataInfo: () => []
});
</script>

<template>
  <modelBox :title="title">
    <div v-loading="loading" class="base-model-loading">
      <div v-if="dataInfo.length" class="base-model-content">
        <div class="model-content-top">
          <div class="content-top-left">
            <div v-for="item in dataInfo.slice(0, 4)" :key="item.label" class="base-model-item">
              <div class="base-model-item-label">{{ item.label }}</div>
              <div class="base-model-item-value">
                <ReTags v-if="item.tags" :tags="item.tags" size="default" />
                <div v-else class="item-value-text">
                  <ReTextTooltip :content="item.value" />
                </div>
              </div>
            </div>
          </div>
          <div class="content-top-line" />
          <div class="content-top-right">
            <div v-for="item in dataInfo.slice(4, 8)" :key="item.label" class="base-model-item">
              <div class="base-model-item-label">{{ item.label }}</div>
              <div class="base-model-item-value">
                <ReTags v-if="item.tags" :tags="item.tags" size="default" />
                <div v-else class="item-value-text">
                  <ReTextTooltip :content="item.value" />
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="model-content-bottom">
          <div v-for="item in dataInfo.filter((ite, ind) => ind === 9)" :key="item.label" class="base-model-item">
            <div class="base-model-item-label">{{ item.label }}</div>
            <div class="base-model-item-value">
              <ReTextTooltip :content="item.value" />
            </div>
          </div>
        </div>
      </div>
      <div v-else><px-empty class="px-empty-common" /></div>
    </div>
  </modelBox>
</template>

<style lang="scss" scoped>
.base-model-loading {
  width: 100%;
  height: 100%;

  .base-model-content {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: space-around;
    width: 100%;
    height: 100%;
    padding: 16px 0 0;

    .base-model-item {
      display: flex;
      gap: 24px;
      align-items: center;
      justify-content: space-between;
      color: #4f4f4f;

      .base-model-item-label {
        max-width: 92px;
        color: #888;
      }

      .base-model-item-value {
        display: flex;
        flex: 1;
        justify-content: flex-end;
        width: 0;

        .item-value-text {
          max-width: 100%;
        }
      }
    }

    .model-content-top {
      display: flex;
      flex: 2;
      gap: 24px;
      align-items: stretch;
      justify-content: space-between;
      width: 100%;

      .content-top-left {
        display: flex;
        flex: 1;
        flex-direction: column;
        gap: 16px;
        justify-content: space-around;
        height: 100%;
      }

      .content-top-line {
        width: 1px;
        background-color: #eee;
      }

      .content-top-right {
        display: flex;
        flex: 1;
        flex-direction: column;
        gap: 16px;
        justify-content: space-around;
        height: 100%;
      }
    }

    .model-content-bottom {
      display: flex;
      flex: 1;
      flex-direction: column;
      gap: 16px;
      justify-content: space-around;
    }
  }
}
</style>
